package com.edu.exam.enums.curriculum;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 干扰效果枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum InterferenceEffect implements BaseEnum {
    CORRECT_ANSWER("CORRECT_ANSWER", "正确答案"),
    STRONG_INTERFERENCE("STRONG_INTERFERENCE", "强干扰项"),
    MODERATE_INTERFERENCE("MODERATE_INTERFERENCE", "中等干扰项"),
    WEAK_INTERFERENCE("WEAK_INTERFERENCE", "弱干扰项"),
    POOR_INTERFERENCE("POOR_INTERFERENCE", "干扰效果差");

    private final String code;
    private final String description;

    InterferenceEffect(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static InterferenceEffect fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("InterferenceEffect code cannot be null or empty");
        }
        for (InterferenceEffect effect : values()) {
            if (effect.getCode().equals(code)) {
                return effect;
            }
        }
        throw new IllegalArgumentException("Unknown InterferenceEffect code: " + code);
    }

    public static InterferenceEffect fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("InterferenceEffect description cannot be null or empty");
        }
        for (InterferenceEffect effect : values()) {
            if (effect.getDescription().equals(description)) {
                return effect;
            }
        }
        throw new IllegalArgumentException("Unknown InterferenceEffect description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}